package com.zhenwei.zscm.controller;

import cn.hutool.core.util.StrUtil;
import cn.hutool.extra.pinyin.PinyinUtil;
import com.zhenwei.zscm.common.annotations.MethodName;
import com.zhenwei.zscm.common.base.RestMsg;
import com.zhenwei.zscm.common.base.RestResult;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/util")
@MethodName("工具类接口")
public class UtilController {

    @MethodName("获取中文拼音")
    @GetMapping("/getPY")
    public RestResult getPY(@RequestParam String cn){
        if(StrUtil.isBlank(cn)){
            return RestResult.fail(RestMsg.PARAM_IS_EMPTY);
        }
        String pinyin = PinyinUtil.getPinyin(cn);
        return RestResult.success(pinyin.replace(" ", ""),0L);
    }
}
